using System;
using UnityEngine;

public class BoardWidgetHandler : MonoBehaviour, IWidget, IHandlerBase
{
	public void DoDataExchange()
	{
	}

	public void SetData(bool isUp, Point _point, byte[] _editMinPoint, int color = -1, bool isEdit = false)
	{
		this.point = _point;
		if (isEdit)
		{
			if (GameMode.gameMode == GameType.TRIANGLE)
			{
				this.sprite.spriteName = ((!isUp) ? "block_triangle_1" : "block_triangle_0");
			}
			else if (GameMode.gameMode == GameType.SQUARE)
			{
				this.sprite.spriteName = "block_square";
			}
			else if (GameMode.gameMode == GameType.HEXA)
			{
				this.sprite.spriteName = "block_hexa";
			}
			else if (GameMode.gameMode == GameType.RHOMBUS)
			{
				this.sprite.spriteName = "block_rhombus";
			}
			else if (GameMode.gameMode == GameType.TANGRAM)
			{
				int num = (_point.x + (int)_editMinPoint[0] + (((_point.y + (int)_editMinPoint[1]) % 2 != 0) ? 2 : 0)) % 4;
				this.sprite.spriteName = string.Format("block_tangram_{0}", num);
			}
		}
		else if (GameMode.gameMode == GameType.TRIANGLE)
		{
			this.sprite.spriteName = ((!isUp) ? "background_triangle_1" : "background_triangle_0");
		}
		else if (GameMode.gameMode == GameType.SQUARE)
		{
			this.sprite.spriteName = "background_square";
		}
		else if (GameMode.gameMode == GameType.HEXA)
		{
			this.sprite.spriteName = "background_hexa";
		}
		else if (GameMode.gameMode == GameType.RHOMBUS)
		{
			this.sprite.spriteName = "background_rhombus";
		}
		else if (GameMode.gameMode == GameType.TANGRAM)
		{
			int num2 = (_point.x + (int)_editMinPoint[0] + (((_point.y + (int)_editMinPoint[1]) % 2 != 0) ? 2 : 0)) % 4;
			this.sprite.spriteName = string.Format("background_tangram_{0}", num2);
		}
		if (GameMode.gameMode == GameType.TRIANGLE)
		{
			if (isUp)
			{
				this.sprite_outline.spriteName = "outline_triangle_0";
			}
			else
			{
				this.sprite_outline.spriteName = "outline_triangle_1";
			}
		}
		else if (GameMode.gameMode == GameType.SQUARE)
		{
			this.sprite_outline.spriteName = "outline_square";
		}
		else if (GameMode.gameMode == GameType.HEXA)
		{
			this.sprite_outline.spriteName = "outline_hexa";
		}
		else if (GameMode.gameMode == GameType.RHOMBUS)
		{
			this.sprite_outline.spriteName = "outline_rhombus";
		}
		else if (GameMode.gameMode == GameType.TANGRAM)
		{
			int num3 = (_point.x + (int)_editMinPoint[0] + (((_point.y + (int)_editMinPoint[1]) % 2 != 0) ? 2 : 0)) % 4;
			this.sprite_outline.spriteName = string.Format("outline_tangram_{0}", num3);
		}
		this.SetMesh(color);
		this.DoDataExchange();
	}

	private void SetMesh(int color = -1)
	{
		if (color > -1 && color < 255)
		{
			this.sprite_ren.material.SetFloat("_OriginColor", 0f);
			this.sprite_ren.material.SetFloat("_MultiColor", 1f);
			this.sprite_outline_ren.material.SetFloat("_OriginColor", 1f);
			this.sprite_outline_ren.material.SetFloat("_MultiColor", 0f);
			MultiColorExt.SetColor(this.filter, color);
		}
		else
		{
			this.sprite_ren.material.SetFloat("_OriginColor", 1f);
			this.sprite_ren.material.SetFloat("_MultiColor", 0f);
			this.sprite_outline_ren.material.SetFloat("_OriginColor", 1f);
			this.sprite_outline_ren.material.SetFloat("_MultiColor", 0f);
		}
	}

	public MeshFilter filter;

	public Renderer sprite_ren;

	public Renderer sprite_outline_ren;

	public tk2dSprite sprite;

	public tk2dSprite sprite_outline;

	public Point point;
}
